package com.geek.util;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.regex.Pattern;

/**
 * @package com.geek.util
 * @description 正则表达式校验类
 * @auther Goliath
 * @createTime 2012-8-1 上午09:52:17
 * @modifyTime
 */
public class RegularExpressionUtil {
	// IP地址
	public static final String REGULAR_IP = "^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})){3}$";
	
	// 校验IP地址
	public static boolean expressionIp(String ip){
		return Pattern.matches(REGULAR_IP, ip);
	}
	
	public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
		System.out.println(expressionIp("255.0.0.0"));
		String methodName = "expressionIp";
		Method method = RegularExpressionUtil.class.getMethod(methodName, String.class);
		System.out.println(method.invoke(null, "255.0.0.0"));
	}
}
